$(function () {
   var loginUrl = '/access/login';

   $('#login').click(function () {
       var mail = $('#mail').val();
       var password = $('#password').val();
       if (mail == '' && password == '') {
          $('#warn').text('信息填写不全');
       }else {
          var admin = {};
          admin.mail = mail;
          admin.password = password;
          var formData = new FormData();
          formData.append("adminStr",JSON.stringify(admin));
          $.ajax({
              url:loginUrl,
              type:"POST",
              data:formData,
              contentType:false,
              processData:false,
              cache:false,
              success:function (data){
                 alert(data.message);
                 if (data.code==200){
                    //登录成功跳转到主页面
                     window.location.href = '/frontend/index';
                 }
              }
          })
       }
   });


    $('#toRegister').click(function () {
        window.location.href = '/frontend/register';
    })
});